<script>
import { CommonBusinessForm } from 'jdf-common-biz';
import BmhyjlService from '@/api/domains/bmhyjl/BmhyjlService';

export default {
  extends: CommonBusinessForm,
  data() {
    return {
      // 后台服务
      service: new BmhyjlService(),
      // 主抄送是否获取网关数据, false为不获取，true为获取
      isGateWayData: false,
      // 采用ucfg的数据字典，不采用数据库表中字典值
      isSelfDict: false,
      // 表单字段布局配置
      formConfigs: [
        [
          {
            formElCode: 'dateStar',
            colSpan: 12,
            elType: 'DatePicker',
            attrs: {
              format: 'yyyy年M月d日',
              'value-format': 'yyyy年M月d日',
            },
          },
          {
            formElCode: 'userName',
            colSpan: 12,
          },
        ],
        [
          {
            formElCode: 'meetingPlace',
            colSpan: 24,
            attrs: {
              maxlength: 200,
            },
          },
        ],
        [
          {
            formElCode: 'title',
            colSpan: 24,
            attrs: {
              maxlength: 200,
            },
          },
        ],
        [
          {
            formElCode: 'moderator',
            colSpan: 24,
            showBtn: true,
            visibleField: 'identityTreeVisible',
            btnObj: {
              name: '选择主持人',
              btnAttrs: {
                type: 'primary',
              },
            },
            treeAttrs: {
              filterable: true,
              treeId: sessionStorage.getItem('treeId'),
              // 展开的层级，为-1时默认不展开，为0时展开第一层...，依此类推, 默认 1
              expandLevel: 1,
            },
          },
        ],
        [
          {
            formElCode: 'conferee',
            colSpan: 24,
            showBtn: true,
            btnObj: {
              name: '选择人员',
              btnAttrs: {
                type: 'primary',
              },
            },
            visibleField: 'identityTreeVisible',
            treeAttrs: {
              multiple: true,
              // 如果是多选，是否在选中节点后，在左侧树中移除选中的节点，multiple属性为true时生效，默认false
              multipleSelectRemoveLeft: true,
              filterable: true,
              treeId: sessionStorage.getItem('treeId'),
              // 展开的层级，为-1时默认不展开，为0时展开第一层...，依此类推, 默认 1
              expandLevel: 1,
            },
          },
        ],
        [
          {
            formElCode: 'remark',
            colSpan: 24,
            attrs: {
              type: 'textarea',
              maxlength: 400,
            },
          },
        ],
      ],
    };
  },
  inject: ['uploadFormBlob'],
  watch: {
    'formData.title': {
      handler(val) {
        this.$emit('update:processTitle', `[${this.formData.orgName}]${val || ''}`);
      },
    },
    formData: {
      handler(val) {
        this.$emit('changeBizFormData', val);
      },
      deep: true,
    },
  },
  methods: {
    /**
     * 表单数据初始化后调用的方法
     * */
    afterInit() {
      this.$emit('update:documentFormTitle', '在此设置表单顶部红头标题');
    },
    /**
     * 将当前表单HTML上传到指定空间
     */
    customBeforeClickSubmitBtn() {
      return this.uploadFormBlob('测试表单', [], {
        owner: this.piid,
        spaceCode: 'default',
      });
    },
  },
};
</script>
